package com.eastfair.pay.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 结算单
 * </p>
 *
 * @author clm
 * @since 2022-06-08
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("pay_settlement")
@ApiModel(value = "Settlement", description = "结算单")
@AllArgsConstructor
public class Settlement extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 结算单号
     */
    @ApiModelProperty(value = "结算单号")
    @Size(max = 30, message = "结算单号长度不能超过30")
    @TableField(value = "settle_number", condition = LIKE)
    @Excel(name = "结算单号")
    private String settleNumber;

    /**
     * 客户id
     */
    @ApiModelProperty(value = "客户id")
    @TableField(value = "cutomer_id")
    @Excel(name = "客户id")
    private Long cutomerId;

    /**
     * 客户名称
     */
    @ApiModelProperty(value = "客户名称")
    @Size(max = 255, message = "客户名称长度不能超过255")
    @TableField(value = "cutomer_name", condition = LIKE)
    @Excel(name = "客户名称")
    private String cutomerName;

    /**
     * 展会id
     */
    @ApiModelProperty(value = "展会id")
    @TableField(value = "exhibition_id")
    @Excel(name = "展会id")
    private Long exhibitionId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 255, message = "展会名称长度不能超过255")
    @TableField(value = "exhibition_name", condition = LIKE)
    @Excel(name = "展会名称")
    private String exhibitionName;

    /**
     * 结算日期
     */
    @ApiModelProperty(value = "结算日期")
    @TableField(value = "settle_time")
    @Excel(name = "结算日期", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime settleTime;

    /**
     * 应付金额
     */
    @ApiModelProperty(value = "应付金额")
    @TableField(value = "payable_amount")
    @Excel(name = "应付金额")
    private BigDecimal payableAmount;

    /**
     * 已付金额
     */
    @ApiModelProperty(value = "已付金额")
    @TableField(value = "payed_amount")
    @Excel(name = "已付金额")
    private BigDecimal payedAmount;

    /**
     * 应退金额
     */
    @ApiModelProperty(value = "应退金额")
    @TableField(value = "return_amount")
    @Excel(name = "应退金额")
    private BigDecimal returnAmount;

    /**
     * 已退金额
     */
    @ApiModelProperty(value = "已退金额")
    @TableField(value = "returned_amount")
    @Excel(name = "已退金额")
    private BigDecimal returnedAmount;

    /**
     * 开票金额
     */
    @ApiModelProperty(value = "开票金额")
    @TableField(value = "invoice_amount")
    @Excel(name = "开票金额")
    private BigDecimal invoiceAmount;

    /**
     * 系统code
     */
    @ApiModelProperty(value = "系统code")
    @Size(max = 20, message = "系统code长度不能超过20")
    @TableField(value = "system_code", condition = LIKE)
    @Excel(name = "系统code")
    private String systemCode;

    /**
     * 场地保证金
     */
    @ApiModelProperty(value = "场地保证金")
    @TableField(value = "space_bond")
    @Excel(name = "场地保证金")
    private BigDecimal spaceBond;

    /**
     * 服务预存款
     */
    @ApiModelProperty(value = "服务预存款")
    @TableField(value = "service_bond")
    @Excel(name = "服务预存款")
    private BigDecimal serviceBond;

    /**
     * 退款申请状态
     */
    @ApiModelProperty(value = "退款申请状态")
    @TableField(value = "refund_apply_status")
    @Excel(name = "退款申请状态")
    private String refundApplyStatus;


    @Builder
    public Settlement(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String settleNumber, Long cutomerId, String cutomerName, Long exhibitionId, String exhibitionName, LocalDateTime settleTime, 
                    BigDecimal payableAmount, BigDecimal payedAmount, BigDecimal returnAmount, BigDecimal returnedAmount, BigDecimal invoiceAmount, String systemCode) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.settleNumber = settleNumber;
        this.cutomerId = cutomerId;
        this.cutomerName = cutomerName;
        this.exhibitionId = exhibitionId;
        this.exhibitionName = exhibitionName;
        this.settleTime = settleTime;
        this.payableAmount = payableAmount;
        this.payedAmount = payedAmount;
        this.returnAmount = returnAmount;
        this.returnedAmount = returnedAmount;
        this.invoiceAmount = invoiceAmount;
        this.systemCode = systemCode;
    }

}
